<?php

include ("../lib/BLL/DonViBLL.php");
include ("../lib/BLL/DmNganhBLL.php");
include ("../lib/BLL/DonViHocVuBLL.php");
include ("../lib/BLL/DmMonHocBLL.php");
include ("../lib/BLL/DmCaHocBLL.php");
include ("../lib/BLL/KhoaHocBLL.php");
include ("../lib/BLL/LopMonBLL.php");
include ("../lib/BLL/CanBoBLL.php");
include ("../lib/BLL/LapLichBLL.php");
include ("../lib/BLL/ChiTietLopMonBLL.php");
include ("../lib/BLL/QuaTrinhLopMonBLL.php");

$donvi=new DonViBLL();
$nganh=new DmNganhBLL();
$dvhv=new DonViHocVuBLL();
$monhoc= new DmMonHocBLL();
$cahoc= new DmCaHocBLL();
$khoahoc= new KhoaHocBLL();
$canbo= new CanBoBLL();
$lopmonBLL=new LopMonBLL();
$laplich=new LapLichBLL();
$ctlm= new ChiTietLopMonBLL();
$qllm= new QuaTrinhLopMonBLL();

$lopmonDAL=new LopMon();
$laplichDAL=new LapLich();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$lich=$nganh_lopmon=$ds_lichthi=$lophc=$dslophc=null;
$khoa="";


if(isset($_POST['xem'])){
    $madonvi=$_POST['donvi'];
    $madvhv=$_POST['dvhv'];
    $makhoahoc=$_POST['khoahoc'];
    $lophc=$_POST['lophc'];
}else{
    $madonvi='01';//$_POST['donvi'];
    $madvhv='1-2013';//$_POST['dvhv'];
    $makhoahoc='2013';//$_POST['khoahoc'];
    $lophc="";
}

    if($lophc!=""){
            $lich=$lopmonBLL->getlopmon_donvi_diemdk($madonvi,$madvhv,$lophc);   
    }else{
            $lich=$lopmonBLL->getlopmon_donvi_diemdk($madonvi,$madvhv,"");    
        }
    
    if(count($lich)!=0){
        $nganh_lopmon=$lopmonBLL->getnganh_lopmon($madonvi,$madvhv);
        $dslopmon="";
        foreach($lich as $lm){
            $dslopmon.="'".$lm['ma_lopmon']."',";
        }
        $dslopmon=rtrim($dslopmon,',');
        $ds_lichthi=$ctlm->Getngaythi_lopmon($dslopmon);
        $dslophc=$qllm->GetLophc_lopmon($dslopmon);              
    }


$smarty->assign('lich',$lich);
$smarty->assign('ds_lichthi',$ds_lichthi);
$smarty->assign('nganh_lopmon',$nganh_lopmon);
$smarty->assign('soluonglopmon',count($lich));
$smarty->assign('dslophc',$dslophc);
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

$ds_donvi=$donvi->getListDonVi_Lienket();
$smarty->assign('ds_donvi',$ds_donvi);

$ds_dvhv= $dvhv->getListDonViHocVu();
$smarty->assign('ds_dvhv',$ds_dvhv);

$ds_cahoc=$cahoc->getListDmCaHoc();
$smarty->assign('ds_cahoc',$ds_cahoc);

$ds_namkhoahoc=$khoahoc->getListNamKhoaHoc();
$smarty->assign('ds_namkhoahoc',$ds_namkhoahoc);

$ds_canbo=$canbo->getListCanBo();
$smarty->assign('ds_canbo',$ds_canbo);

$dslop_hanhchinh="";
$ex=mysql_query("SELECT * FROM tbl_lop");
while($row=mysql_fetch_array($ex)){
    $dslop_hanhchinh[]=$row;
}
$smarty->assign('dslop_hanhchinh',$dslop_hanhchinh);
$smarty->display('diem/dsnhapdiemdk.tpl');   
?>












